<?php
session_start();
$action = $_POST['action'];
include_once 'conn.php';
$bbs = new Bbs();
$result = array();
switch ($action){
    case 'postContent':
        if($_SESSION['loggedUserID'] ?? ''){
            $result = $bbs->postContent($_POST,$_SESSION['loggedUserID']);
        }
        else{
            $result = array('code'=>-1,'msg'=>'请登录后发贴');
        }
        break;
    case 'postReply':
        if($_SESSION['loggedUserID'] ?? ''){
            $result = $bbs->postReply($_POST,$_SESSION['loggedUserID']);
        }
        else{
            $result = array('code'=>-1,'msg'=>'请登录后发贴');
        }
        break;
    case 'getData':
        $result = $bbs->getData($_POST);
        break;
    default:
}
echo json_encode($result);
